package com.uphone.kingmall.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.bean.FollowInfoBean;

/**
 * <pre>
 *     author : 孙增艳
 *     e-mail : sunzengyan@outlook.com
 *     time   : 2019/2/26
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class RvOrderFollowAdapter extends BaseQuickAdapter<FollowInfoBean.SendInfoBean.TracesBean, BaseViewHolder> {

    private final String state;
    private Context context;

    public RvOrderFollowAdapter(Context context, String state) {
        super(R.layout.kingmall_item_rv_order_follow);
        this.context = context;
        this.state = state;
    }

    @Override
    protected void convert(BaseViewHolder helper, FollowInfoBean.SendInfoBean.TracesBean item) {
        LinearLayout llShou = helper.getView(R.id.ll_wuliu_shou);
        LinearLayout llIng = helper.getView(R.id.ll_wuliu_ing);
        LinearLayout llOk = helper.getView(R.id.ll_wuliu_ok);
        LinearLayout llFa = helper.getView(R.id.ll_wuliu_fa);
        llShou.setVisibility(View.GONE);
        llIng.setVisibility(View.GONE);
        llOk.setVisibility(View.GONE);
        llFa.setVisibility(View.GONE);
        //	物流状态：2-在途中,3-签收,4-问题件
        if (helper.getLayoutPosition() == 0) {
            //顶部
            if (TextUtils.equals("2", state)) {
                llIng.setVisibility(View.VISIBLE);
            } else if (TextUtils.equals("3", state)) {
                llShou.setVisibility(View.VISIBLE);
            } else if (getData().size() == 0 || getData().size() == 1) {
                llFa.setVisibility(View.VISIBLE);
            } else {
                llOk.setVisibility(View.VISIBLE);
            }
        } else if (helper.getLayoutPosition() == getData().size() - 1) {
            llFa.setVisibility(View.VISIBLE);
        } else {
            llOk.setVisibility(View.VISIBLE);
        }
        if (helper.getAdapterPosition() == 0) {
            llShou.setVisibility(View.VISIBLE);
            llIng.setVisibility(View.GONE);
            llOk.setVisibility(View.GONE);
            llFa.setVisibility(View.GONE);
        } else if (helper.getAdapterPosition() == 1) {
            llShou.setVisibility(View.GONE);
            llIng.setVisibility(View.VISIBLE);
            llOk.setVisibility(View.GONE);
            llFa.setVisibility(View.GONE);
        } else {
            if (helper.getAdapterPosition() == getData().size() - 1) {
                llShou.setVisibility(View.GONE);
                llIng.setVisibility(View.GONE);
                llOk.setVisibility(View.GONE);
                llFa.setVisibility(View.VISIBLE);
            } else {
                llShou.setVisibility(View.GONE);
                llIng.setVisibility(View.GONE);
                llOk.setVisibility(View.VISIBLE);
                llFa.setVisibility(View.GONE);
            }
        }
        helper.setText(R.id.tv_date, item.getAcceptTime())
                .setText(R.id.tv_content, item.getAcceptStation());
    }
}
